<template>
	<view class="pages">
		<view class="search_box">
			<view class="search">
				<view class="input">
					<input type="text" placeholder="搜一搜" v-model="searchContent" confirm-type="search" @confirm="search" />
					<i class="iconfont" style="margin-left: 60rpx;" @click="search">&#xe60a</i>
				</view>
			</view>
		</view>
		<view class="info2">
			<view class="content" v-if="activityList.length > 0">
				<view class="activityList" v-for="(item, index) in activityList" :key="index"  @click="goDetail(item.id)">
					<view class="title">
						<view class="title-text">
							{{ item.title }}
						</view>
					</view>
					<view class="status">
						<view class="status status0" v-if="item.activity_status == 1">
							筹备中
						</view>
						<view class="status status1" v-if="item.activity_status == 2">
							报名中
						</view>
						<view class="status status2" v-if="item.activity_status == 3">
							已结束
						</view>
					</view>
					<view class="image">
						<image :src="rq.imgUrl(item.image)" mode="aspectFill"></image>
					</view>
					<view class="con">
						<view class="con1">
							<image src="https://pw.qyang.cc/static/svg/biao.svg" mode="aspectFill"
								style="width: 30rpx; height: 30rpx; margin-right: 15rpx"></image>
							{{ item.issue }}
						</view>
						<view class="con1">
							<image src="https://pw.qyang.cc/static/svg/dingwei.svg" mode="aspectFit"
								style="width: 30rpx; height: 30rpx; margin-right: 15rpx"></image>{{ item.address }}
						</view>
						<view class="con1 con2">
							<view class="con2-img">
								<image v-for="i,a in item.join_avatar" :key="a" :src="rq.imgUrl(i)" mode=""></image>
							</view>
							<view class="con2-text">
								<span style="color: #ff7883">{{ item.join_num }}人</span> 报名
							</view>
						</view>
						<view class="buts">
							<view class="but" v-if="item.activity_status == 2" @click.stop="groupCode(item.id)">群二维码</view>
							<view class="but" v-if="item.activity_status == 3" @click.stop="handleDelete(item.id)">删除</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-popup :show="showTip" mode="center" @close="showTip=false" @open="showTip=true" closeable="true"
			round="10">
			<view class="pop-bg">
				提示
				<view class="text">
					确认删除此活动？
				</view>
				<view class="btn">
					<view class="confirm" @click="showTip=false">我再想想</view>
					<view class="cancel" @click="confirmTip">确认删除</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				activityList: [],
				params:{
					page:1
				},
				total:0,
				currentId:null,
				showTip:false
			};
		},
		onReachBottom() {
			if (this.activityList.length > this.total) {
				this.params.page++
				this.getList(true)
			}
		},
		onPullDownRefresh() {
			this.params.page = 1
			this.getList()
			uni.hideNavigationBarLoading();
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getList(more) {
				this.rq.getData('dynamic/activity').then(res => {
					if (more) {
						this.activityList = [...this.activityList, ...res.data.data]
					} else {
						this.activityList = res.data.data
					}
					this.total = res.data.total
					uni.stopPullDownRefresh();
				}).catch(err => {
					uni.stopPullDownRefresh();
				})
			},
			goDetail(id){
				uni.navigateTo({
					url:'/subpages/activity/detail?id='+id
				})
			},
			groupCode(id) {
				uni.navigateTo({
					url: "/subpages/registered-activities/group-ewm/group-ewm?id="+id,
				});
			},
			handleDelete(id){
				this.currentId = id
				this.showTip = true
			},
			confirmTip(){
				this.rq.getData('User_Activity/delete',{id:this.currentId}).then(res=>{
					if(res.code === 1){
						uni.showToast({
							title:'删除成功~',
							icon:'none'
						})
						this.showTip = false
						this.params.page = 1
						this.getList()
					}
				})
			},
		},
	};
</script>

<style lang="scss" scoped>
	.pages {
		.search_box{
			padding:16rpx 30rpx 14rpx;
			background: #fff;
			.search {
				// width: 92%;
				height: 35px;
				border-radius: 99px;
				opacity: 1;
			
				background: #fcf9f9;
			
				box-sizing: border-box;
				border: 1px solid #333333;
				margin: 0 auto 20rpx;
				display: flex;
				align-items: center;
			
				.input {
					display: flex;
					align-items: center;
					// justify-content: center;
					width: 100%;
			
					input {
						padding-left: 30rpx;
						font-family: 阿里巴巴普惠体 2;
						font-size: 13px;
						font-weight: normal;
						line-height: 13px;
						letter-spacing: 0px;
						color: #999999;
						width: 80%;
					}
				}
			}
		}
		.info2 {
			.content {
				padding: 20rpx 30rpx 100rpx 30rpx;
				position: relative;
				background-color: #f4f4f4;

				.activityList {
					margin-bottom: 30rpx;
					border-radius: 10px;
					background-color: #ffffff;
					width: 100%;
					// height: 686rpx;
					display: flex;
					flex-direction: column;
					align-items: flex-start;
					position: relative;

					.title {
						font-size: 14px;
						font-weight: 600;
						line-height: 2px;
						letter-spacing: 0px;
						color: #333333;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						// // width: 600rpx;
						// padding: 30rpx;
						// position: relative;
						// margin: 10rpx 0;
						padding: 10rpx 28rpx;
						position: relative;
						margin: 10rpx 0;
						width: 550rpx;
						display: flex;
						align-items: center;

						.title-text {
							width: 500rpx;
							height: 40rpx;
							line-height: 40rpx;
							text-overflow: ellipsis;
							overflow: hidden;
							white-space: nowrap;
						}
					}

					.image {
						width: 100%;
						height: 400rpx;

						image {
							width: 100%;
							height: 400rpx;
						}
					}

					.status {
						position: absolute;
						right: 0;
						// margin-right: 30rpx;
						width: 54.64px;
						height: 24.72px;
						border-radius: 0px 8px 0px 8px;
						opacity: 1;

						font-size: 13px;
						font-weight: 500;
						line-height: 12px;
						text-align: center;
						letter-spacing: 0px;
						// background: #84E28C;
						color: #ffffff;
						display: flex;
						align-items: center;
						justify-content: center;

						.status0 {
							background: #84E28C;
						}
						
						.status1 {
							background: #AE9CFE;
						}
						
						.status2 {
							background: rgba(153, 153, 153, 0.1);
							color: #999999;
						}
					}

					.con {
						width: 100%;
						padding: 20rpx 0;

						.con1 {
							font-family: 阿里巴巴普惠体 2;
							font-size: 13px;
							font-weight: normal;
							line-height: 12px;
							letter-spacing: 0px;
							margin: 20rpx;
							color: #333333;
							display: flex;
							align-items: center;
						}

						.con2 {
							display: flex;

							.con2-img {
								width: 460rpx;
								overflow: hidden;
								text-overflow: ellipsis;
								white-space: nowrap;

								image {
									width: 21px;
									height: 21px;
									border-radius: 50%;
									margin-right: 10rpx;
								}
							}

							.con2-text {
								font-family: PingFang SC;
								font-size: 14px;
								font-weight: normal;
								line-height: 12px;
								letter-spacing: 0px;

								font-variation-settings: "opsz" auto;
								/* 累计 */
								color: #000000;
							}
						}

						.buts {
							display: flex;
							justify-content: flex-end;

							.but {
								padding: 8rpx 30rpx;
								border-radius: 25rpx;
								font-size: 24rpx;
								background: #f7f7f7;
								margin-right: 20rpx;
							}
						}
					}
				}
			}
		}
	}
	.pop-bg {
		width: 606rpx;
		height: 303rpx;
		border-radius: 8px;
		opacity: 1;
		background: #FFFFFF;
		font-family: PingFang SC;
		font-size: 16px;
		font-weight: normal;
		line-height: 14px;
		letter-spacing: 0px;
		color: #333333;
		padding: 40rpx;
		padding-bottom:0;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		text-align: center;
		
		.text {
			margin: 50rpx 0 0;
		}
	
		.btn {
			display: flex;
			align-items: center;
			justify-content: space-around;
			margin-top: auto;
			width: 100%;
	
			.cancel {
				width: 98px;
				height: 34px;
				border-radius: 102px;
				opacity: 1;
	
				background: #F7F7F7;
	
				border: 1px solid #F7F7F7;
				color: #333333;
				display: flex;
				align-items: center;
				justify-content: center;
			}
	
			.confirm {
				width: 98px;
				height: 34px;
				border-radius: 102px;
				opacity: 1;
	
				background: #FF5866;
	
				border: 1px solid #FF5866;
				color: #ffffff;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
	}
</style>